#coding=utf-8
'''
20天突破入场信号成功率的研究
'''

from stockdb.misc import *
import strategy.basic as basic
import strategy.turtle.filter as tut

code = '601600'
s = find_stock(code)

print 'ipo:%s'%s.ipo
tds = s.tds_since('2005-01-01')
print len(tds)

tdfilter = basic.TDFilter(tds)


'''
入场信号条件1: td.close > td.pre.top(20)
'''
r1 = tdfilter.filter_by(tut.breakout2_filter, 20)
tds = r1.all()
print len(tds)
for t in tds:
    print t.index_of(), t.date, '%.2f'%t.close

'''
入场信号条件2: 20天内首次突破;
             也就是说该交易日前20天,没有一天是突破20天最高.
'''
#r2 = r1.filter_by(tut.first_breakout_filter, 20)
#tds = r2.all()
#print len(tds)
#print tds    
